package com.baifendian.common.task;

import com.baifendian.common.utils.DateUtils;
import com.baifendian.dao.entity.RcApiInterStat;
import com.baifendian.dao.entity.RcDataInterStat;
import com.baifendian.service.RcApiSysStatService;
import com.baifendian.service.RcDataInterStatService;
import java.util.Date;
import java.util.List;
import org.springframework.util.ObjectUtils;

/**
 * @author peng.guo on 2018/3/7.
 */
public class RcDataInterStatByDayTask implements Runnable  {

  private String name;

  private RcDataInterStatService rcDataInterStatService;

  public RcDataInterStatByDayTask(RcDataInterStatService rcDataInterStatService,String name) {
    this.name = name;
    this.rcDataInterStatService = rcDataInterStatService;
  }
  //当日top10
  @Override
  public void run() {
//    Date date = DateUtils.stringToDate("02/22/2018");
    Date date = DateUtils.localDateTimeToDate(DateUtils.getCurrentTime());
    List<RcDataInterStat> rcDataInterStatList = rcDataInterStatService.getRcDataInterStatByDay(date);
    if(ObjectUtils.isEmpty(rcDataInterStatList)){
      return;
    }
    rcDataInterStatService.delRcDataInterStatByDay();
    rcDataInterStatService.saveRcDataInterStat(rcDataInterStatList);
    System.out.println("rcApiInterStatList" + rcDataInterStatList);
  }
}
